#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s1, s2, left, ans; cin >> s1 >> s2;
    int n1 = s1.size(), n2 = s2.size();
    if(n1 < n2 || (n1 == n2 && s1 < s2))
    {
        cout << 0 << endl << s1;
        return 0;
    }
    for(int i = 0; i < n1; ++i)
    {
        left += s1[i];
        ans += stoi(left) / stoi(s2) + '0';
        left = to_string(stoi(left) % stoi(s2));
    }
    while(ans != "0" && ans.front() == '0') ans.erase(ans.begin(), ans.begin() + 1);
    while(left != "0" && left.front() == '0') left.erase(left.begin(), left.begin() + 1);
    cout << ans << endl << left;
    return 0;
}